package com.jcl.recruit.elasticsearch.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.elasticsearch.resume.dao.SearchResumeSelfEvaluationDao;
import com.jcl.recruit.elasticsearch.resume.model.SearchResumeSelfEvaluation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SearchResumeSelfEvaluationLogic
 * @Author yyliu
 * @Date 2018/11/17 11:53
 * @Version 1.0
 **/
@Component
public class SearchResumeSelfEvaluationLogic {

    @Autowired
    private SearchResumeSelfEvaluationDao searchResumeSelfEvaluationDao;

    public Map<Integer, SearchResumeSelfEvaluation> findEntityMapByResumeIds(List<Integer> resumeIds) {
        Map<Integer, SearchResumeSelfEvaluation> dataMap = new HashMap<>();
        List<SearchResumeSelfEvaluation> list = searchResumeSelfEvaluationDao.findListByResumeIds(resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (SearchResumeSelfEvaluation entity : list) {
                dataMap.put(entity.getResumeId(), entity);
            }
        }

        return dataMap;
    }

    public List<SearchResumeSelfEvaluation> findListByResumeIds(List<Integer> resumeIds) {
        return searchResumeSelfEvaluationDao.findListByResumeIds(resumeIds);
    }

    public Map<String, Object> findOneMap(Integer resumeId) {
        return searchResumeSelfEvaluationDao.findOneMap(resumeId);
    }

    public SearchResumeSelfEvaluation findOne(Integer resumeId) {
        return searchResumeSelfEvaluationDao.findOne(resumeId);
    }

    public int add(SearchResumeSelfEvaluation entity) {
        return searchResumeSelfEvaluationDao.add(entity);
    }

    public int batchDeleteByResumeIds(List<Integer> resumeIds) {
        return searchResumeSelfEvaluationDao.batchDeleteByResumeIds(resumeIds);
    }
}
